#include <cstddef>
template <typename T>
class bin_tree_node {
 public:
    T payload;                          // 节点负载
    bin_tree_node *left;                // 左子节点
    bin_tree_node *right;               // 右子节点

    // 节点的构造函数
    bin_tree_node(const T& value) {
        payload = value;
        left = nullptr;
        right = nullptr;
    }

    // 节点的析构函数
    ~bin_tree_node() {
        if (left)
            delete left;
        if (right)
            delete right;
    }
    template <typename c>
    size_t count_if (c cond) const
    {
        size_t count = 0;
        if (cond(payload))
            count++;
        if (left)
            count += left->count_if(cond);
        if (right)
            count += right->count_if(cond);
        return count;
    }

    bin_tree_node* right_child(const T& value)
    {
        if (right)
            return nullptr;

        // Create a new node with the given value
        right = new bin_tree_node(value);
        return right;
    }

    bin_tree_node* left_child(const T& value)
    {
        if (left)
            return nullptr;

        // Create a new node with the given value
        left = new bin_tree_node(value);
        return left;
    }
};

#include <iostream>     // for cin and cout
#include <sstream>      // for ostringstream
#include <string>       // for stod()
#include <cassert>      // for assert()

using namespace std;

int main()
{

    using my_bin_tree_node = bin_tree_node<int>;
    my_bin_tree_node* root = new my_bin_tree_node(0);

    my_bin_tree_node *node = root;
    my_bin_tree_node *last_node = root;
    do {
        string buf;
        cin >> buf;

        int d;
        try {
            size_t sz;
            d = stoi(buf, &sz);
        }
        catch (std::exception& e) {
            break;
        }

        if (d < 0) {
            last_node = node->left_child(d);
        }
        else if (d > 0) {
            last_node = node->right_child(d);
        }
        else {
            if (last_node)
                node = last_node;
        }

    } while (true);

    clog << "count_if\n";
    cout << root->count_if([] (const int& value) {
            return value % 2; });
    cout << endl;
    delete root;
}

